package com.sc.VenusQueryBeta.presenter.login;

import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.login.ForgotPasswordContract;
import com.sc.VenusQueryBeta.model.bean.login.RegisterVerticationBean;
import com.sc.VenusQueryBeta.model.login.ForgotPasswordModel;

import io.reactivex.functions.Consumer;

/**
 * 忘记密码Presenter
 */

public class ForgotPasswordPresenter extends ForgotPasswordContract.ForgotPasswordPresenter {
    @Override
    protected ForgotPasswordContract.IForgotPasswordModel getModel() {
        return ForgotPasswordModel.newInstance();
    }

    @Override
    public void onStart() {

    }
    public static ForgotPasswordPresenter newInstance(){
        return  new ForgotPasswordPresenter();
    }

    @Override
    public void getVerticatinCode(String clientUID, String deviceUID, String deviceType, String registerSmsnum, String areaCode, String flag) {
        mRxManager.register(mIModel.getVerticatinCode(clientUID, deviceUID, deviceType, registerSmsnum, areaCode, flag).subscribe(new Consumer<RegisterVerticationBean>() {
            @Override
            public void accept(RegisterVerticationBean registerVerticationBean) throws Exception {
//                if (mIView != null){
                LogUtils.e("registerVerticationBean.getRegisterSmsnum()=="+registerVerticationBean.getRegisterSmsnum());
//                    return;
//                }
                mIView.showVerticationDataSuccess(registerVerticationBean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("accept");
//                if (mIView != null)
//                    return;
                mIView.showToast("Network error.");
                mIView.showNetworkError();
            }
        }));
    }
}
